import { ref, onMounted } from "vue";
import { ElEmpty } from "element-plus";
import {
  communityListApi,
  buildingListApi,
  cateListApi,
  memberListApi,
} from "../api/hooks";

// 小区名称
export const useCommunityNameList = () => {
  // 小区名列表
  const communityList = ref([]);
  // 定义方法
  const getcommunityList = async () => {
    let res = await communityListApi();
    communityList.value = res.data;
  };

  onMounted(() => {
    getcommunityList();
  });
  return communityList;
};

// 禁用启用
export const useState = () => {
  let stateList = [
    { label: "启用", value: 1 },
    { label: "禁用", value: 0 },
  ];
  return stateList;
};

// 获取楼栋
export const useBuildingList = (code) => {
  const BuildingList = ref([]);
  const getAllBuildingList = async () => {
    // code='CM-8c63d562-199e-4dd2-b08c-55b271a00769'
    const res = await buildingListApi(code);
    BuildingList.value = res.data;
  };
  onMounted(() => {
    getAllBuildingList();
  });
  return BuildingList;
};

// 获取性别状态
export const useGenderStatus = () => {
  const genderStatus = [
    {
      label: "男",
      value: 1,
    },
    {
      label: "女",
      value: 0,
    },
  ];
  return genderStatus;
};

// 获取成员列表
export const useMemberList = () => {
  const memberList = ref([]);
  // 全部获取成员列表
  const getAllMemberList = async () => {
    const res = await memberListApi();
    // console.log(res.data);
    memberList.value = res.data;
  };
  onMounted(() => {
    getAllMemberList();
  });
  return memberList;
};

// 获取成员类型
export const useMemberStatus = () => {
  const memberStatus = [
    {
      label: "业主",
      value: 1,
    },
    {
      label: "家庭成员",
      value: 2,
    },
    {
      label: "租客",
      value: 3,
    },
  ];
  return memberStatus;
};

// 获取活动状态
export const useActivityStatus = () => {
  const activityStatus = [
    {
      label: "有效",
      value: 1,
    },
    {
      label: "无效",
      value: 2,
    },
  ];
  return activityStatus;
};

// 获取保修状态
export const useRepairStatus = () => {
  const repairStatus = [
    {
      label: "待受理",
      value: 0,
    },
    {
      label: "已受理",
      value: 1,
    },
    {
      label: "已维修",
      value: 2,
    },
  ];
  return repairStatus;
};

// 投诉管理
export const useComplainStatus = () => {
  const complainStatus = [
    {
      label: "不匿名",
      value: 2,
    },
    {
      label: "匿名",
      value: 1,
    },
  ];
  return complainStatus;
};

// 信箱管理
export const useMailboxStatus = () => {
  const mailboxStatus = [
    {
      label: "已读回复",
      value: 1,
    },
    {
      label: "未读",
      value: 0,
    },
  ];
  return mailboxStatus;
};

// 广告位置
export const useAdvStatus = () => {
  const advStatus = [
    {
      label: "移动端轮播图",
      value: 1,
    },
    {
      label: "PC端轮播图",
      value: 2,
    },
  ];
  return advStatus;
};

// 资讯管理
export const useCateList = () => {
  const cateList = ref([]);
  // 全部获取资讯管理角色
  const getAllCateList = async () => {
    const res = await cateListApi();
    //!注意数组里面渲染的是catename，不是name
    // console.log(res.data);
    cateList.value = res.data;
  };
  onMounted(() => {
    getAllCateList();
  });
  return cateList;
};

// 文章状态
export const useArticleStatus = () => {
  const articleStatus = [
    {
      label: "显示",
      value: 1,
    },
    {
      label: "隐藏",
      value: 0,
    },
  ];
  return articleStatus;
};

// 通知公告类型
export const useNoticeStatus = () => {
  const noticeStatus = [
    {
      label: "通知",
      value: 1,
    },
    {
      label: "公告",
      value: 2,
    },
  ];
  return noticeStatus;
};

// 投票管理类型
export const useTicketStatus = () => {
  const ticketStatus = [
    {
      label: "单选",
      value: 0,
    },
    {
      label: "多选",
      value: 1,
    },
  ];
  return ticketStatus;
};
